import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:moose_app/core/utils/navigate_util.dart';
import 'package:moose_app/ui/screens/profile/profile_screen.dart';
import 'package:moose_app/ui/values/values.dart';
import 'package:moose_app/ui/widgets/user/user_avatar.dart';

class ATHMimeUserInfo extends StatelessWidget {
  final Function press;

  ATHMimeUserInfo({this.press});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: kSize350,
      padding: EdgeInsets.symmetric(horizontal: kSize24).copyWith(top: kSize20),
      decoration: BoxDecoration(
        color: kColorPrimary,
        boxShadow: [
          BoxShadow(
              color: kColorE2, blurRadius: kSize1, spreadRadius: kSize1)
        ],
      ),
      child: Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              GestureDetector(
                onTap: () {
                  if (null != press) press();
                },
                child: ATHUserAvatar(),
              ),
              Expanded(
                child: Container(
                  margin: kCommonMarin,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        "李白",
                        style: TextStyle(
                            fontSize: kFontSize38, color: Colors.white),
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: <Widget>[
                          Text(
                            "libai@163.com",
                            style: TextStyle(
                                fontSize: kFontSize32, color: Colors.white),
                          ),
                          GestureDetector(
                            onTap: () {
                              ATHNavigator.pushFromRight(
                                  context, ATHProfileScreen.routeName);
                            },
                            child: Row(
                              children: <Widget>[
                                SvgPicture.asset('assets/icons/icon_qrcode.svg',
                                    width: kSize48, color: Colors.white),
                                SvgPicture.asset(
                                    'assets/icons/icon_arrow_right.svg',
                                    width: kSize48,
                                    color: Colors.white),
                              ],
                            ),
                          )
                        ],
                      )
                    ],
                  ),
                ),
              ),
            ],
          ),
          ATHMimeItem()
        ],
      ),
    );
  }
}

class ATHMimeItem extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          ATHMimeInfoItem(title: "关注", count: "96"),
          ATHMimeInfoItem(title: "粉丝", count: "04m"),
          ATHMimeInfoItem(title: "赞", count: "18m"),
        ],
      ),
    );
  }
}

class ATHMimeInfoItem extends StatelessWidget {
  final String count;
  final String title;

  ATHMimeInfoItem({this.count, this.title});

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Text(
          title,
          style: TextStyle(color: Colors.white, fontSize: kFontSize36),
        ),
        Text(
          count,
          style: TextStyle(color: Colors.white, fontSize: kFontSize32),
        ),
      ],
    );
  }
}
